The present invention relates to, for example, a hard disk drive, and more particularly to a disk controller for controlling write buffering.
A hard disk drive (HDD) is connected to a host system such as a computer system or the like and then used as a data storage device. The HDD receives data transferred from the host system and records the data (write data) on a disk, or data recording medium. The HDD reads data from the disk and transfers the data (read data) to the host system. The speed of data transfer between the host system and the HDD (host data transfer) is different from the speed of data transfer in the HDD, namely to and from the disk (disk data transfer). To compensate for the difference between these speeds, the HDD incorporates a buffer memory (RAM).
The buffer memory has a read buffer area and a write buffer area. The read buffer area is provided for temporarily storing data read from the disk. The write buffer areas is provided for temporarily storing data to be written on the disk. The ratio in size between the read and write buffer areas depends on the design specification of the buffer memory. In most cases, the read buffer area is larger than the write buffer area.
Upon receipt of a write command from the host system, the HDD receives write data transferred from the host system. In the HDD, the write data is temporarily stored in the write buffer area of the buffer memory. Meanwhile, the magnetic head for reading data on the disk and writing data therefrom is moved to prescribed position (a target access track) on the disk that is spinning at high speed. The magnetic head is thus prepared to write data on the disk. The write data is read from the write buffer area of the buffer memory, in units sectors. Then, the magnetic head writes data sequentially in those of the sectors provided on the disk which have been designated, first in the first of the designated sectors.
The speed of host data transfer depends on the performance (data-processing ability) of the host system. Hence, the speed of data transfer between one host system and an HDD differs from the speed of data transfer between another host system and an HDD of the same performance.
The speed of host data transfer may be higher than the speed of disk data transfer (i.e., the speed of recording data on the disk). In this case, data is written in the write buffer area faster than data is read from the read buffer area in the buffer memory. The write buffer area will become full more quickly than the read buffer area. Once the write buffer area becomes full, the HDD stops the host data transfer until the write buffer area becomes empty in part. The HDD starts the host data transfer again when some write data is read from the write buffer area, rendering the area partly empty.
Conversely, the speed of host data transfer may be lower than the speed of disk data transfer. If this is the case, the write buffer area of the buffer memory will become empty more quickly than the read buffer area. The write buffer area becomes empty when all write data is read from the buffer memory and written on the disk. Once the write buffer area becomes empty, the HDD starts waiting for any write data that will be transferred from the host system. As soon as write data (data for at least one sector of the disk) is transferred from the host system to the write buffer area, the HDD starts writing the data on the disk.
Recently it is observed that the drive data transfer is faster than the host data transfer in many cases because it takes much time to process write data in the host system and to transfer the data to the HDD. Hence, there is the trend that the write buffer area becomes empty more quickly than the read buffer area. When the write buffer area of the buffer memory becomes empty, the starts waiting for any write data that will be transferred from the host system. The moment write data is transferred from the host system to the write buffer area, the HDD starts writing the data on the disk.
When the HDD stops writing data on the disk, the head moves past the sector in which data is to be written. The HDD can no longer write data on the disk until the disk rotates further once to bring the sector to the head. It is desired that the HDD write data in the designated sector and some following sectors in the same track which has been designated. In other words, the HDD should write data in a plurality of consecutive sectors of a designated track for the time T (e.g., 15 ms) which the disk needs to rotate once.